﻿using IBll;
using MD5Hash;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model;

namespace WebApi.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class UserController : ControllerBase,IUserBll
    {
        private IUserBll bll;

        public UserController(IUserBll bll)
        {
            this.bll = bll;
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        [HttpPost("Add")]
        public Task<int> Add(UserInfo userInfo)
        {
            return bll.Add(userInfo);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="UserId"></param>
        /// <returns></returns>
        [HttpDelete("Delete")]
        public Task<int> Delete(int UserId)
        {
            return bll.Delete(UserId);
        }
        /// <summary>
        /// 显示
        /// </summary>
        /// <returns></returns>
        [HttpGet("GetAll")]
        public dynamic GetAll(string? name, int? Kage, int? Jage, int? tid, int? sex)
        {
            return bll.GetAll(name,Kage,Jage,tid,sex);
        }
        /// <summary>
        /// 逻辑删除
        /// </summary>
        /// <param name="UserId"></param>
        /// <returns></returns>
        [HttpDelete("IsDelete")]
        public Task<int> IsDelete(int UserId)
        {
            return bll.IsDelete(UserId);
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        [HttpPost("Update")]
        public Task<int> Update(UserInfo userInfo)
        {
            return bll.Update(userInfo);
        }
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="name"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        [HttpGet("Login")]
        public int Login(string name, string pwd)
        {
            return bll.Login(name, pwd);
        }
    }
}
